package com.itic.mall.system.project.livingRateCondition.service;

import com.itic.appbase.framework.common.service.CrudService;
import com.itic.appbase.framework.type.LivingRateType;
import com.itic.appbase.framework.utils.StringHelper;
import com.itic.mall.system.inter.project.livingRateCondition.persistence.dao.LivingRateConditionDao;
import com.itic.mall.system.inter.project.livingRateCondition.persistence.model.LivingRateCondition;
import com.itic.mall.system.inter.project.livingRateCondition.persistence.model.LivingRateConditionExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;


@Service
@Transactional
public class LivingRateConditionService
     extends CrudService<LivingRateConditionDao,LivingRateCondition,LivingRateConditionExample> {
    @Autowired
    private LivingRateConditionDao livingRateConditionDao;

    
    public LivingRateCondition getFullLivingRate(LivingRateType type, Double condition) {
    	Map<String, Object> params = new HashMap<String, Object>();
    	params.put("type", type.getType());
    	params.put("condition", condition);
    	LivingRateCondition livingRateCondition = this.livingRateConditionDao.getFullLivingRateCondition(params);
    	return livingRateCondition;
    }
    /**
     * 根据类型查找该类型下的最大条件
     * @param rateType
     * @return
     */
    public Double getMaxCondByType(String rateType){
    	Double maxCond = 0.0;
    	if(StringHelper.isNotBlank(rateType)){
    		maxCond = this.livingRateConditionDao.getMaxCondByType(rateType);
    	}
    	return maxCond;
    }

}